#
# JDK-8U151
#
FROM yi/centos7-jdk8u151
MAINTAINER hai
# install Erlang
RUN yum install -y gcc glibc-devel make ncurses-devel openssl-devel xmlto perl wget xz lsof unixODBC-devel && \
    rpm --rebuilddb && \
    yum install -y tar 
RUN mkdir -p /usr/local/erlang
COPY otp_src_20.2.tar.gz /usr/local/erlang/
WORKDIR /usr/local/erlang/
RUN tar -xvf otp_src_20.2.tar.gz
WORKDIR	/usr/local/erlang/otp_src_20.2/
RUN ./configure --prefix=/usr/local/erlang/ --without-javac
RUN make 
RUN make install 

# ENV
ENV ERL_HOME=/usr/local/erlang/otp_src_20.2/
ENV PATH=$ERL_HOME/bin:$PATH

# install RabbitMQ
RUN mkdir -p /usr/local/rabbitmq
WORKDIR /usr/local/rabbitmq/
COPY rabbitmq-server-generic-unix-3.7.4.tar.xz /usr/local/rabbitmq/
RUN xz -d rabbitmq-server-generic-unix-3.7.4.tar.xz
RUN tar -xvf rabbitmq-server-generic-unix-3.7.4.tar
RUN rm -f rabbitmq-server-generic-unix-3.7.4.tar
RUN yum clean all
COPY rabbit.app /usr/local/rabbitmq/rabbitmq_server-3.7.4/ebin/
ENV RABBITMQ_HOME /usr/local/rabbitmq/rabbitmq_server-3.7.4
ENV PATH $PATH:$RABBITMQ_HOME/sbin

# open ports
EXPOSE 15672
EXPOSE 5672

ENTRYPOINT rabbitmq-plugins enable rabbitmq_management && rabbitmq-server
CMD ["rabbitmq-server"]
